package com.yk.rabbitmq.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author xiaokai
 * @create 2021-01-29 14:53:52
 * @desc...创建连接工具类
 */
public class ConnectionUtil {

    public static ConnectionFactory connectionFactory;

    static {
        connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("localhost");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("admin");
        connectionFactory.setPassword("admin");
        connectionFactory.setVirtualHost("yk");
    }

    public static Connection getConnection() throws Exception {
        return connectionFactory.newConnection();
    }


}
